package fivm.cross.platform.steamobj.sys;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import fivm.cross.platform.ficommon.distinguish.GsonSimpleSerializable;
import fivm.cross.platform.steamobj.log.LogConfigStream;


public class DeviceConfigs extends GsonSimpleSerializable {
	@Expose @SerializedName("ConfigExisted")//该字段来判断该文件不存在
	private boolean configExisted =false;
	@Expose @SerializedName("LoginPath")
	private String loginPath ="/device/login";
	@Expose @SerializedName("VmWorksPath")
	private String vmWorksPath="/data/local/tmp/vmtools";
	@Expose @SerializedName("ControlServerAddr")
	private String controlServerAddr="127.0.0.1";
	@Expose @SerializedName("ControlServerPort")
	private int controlServerPort=8080;
	@Expose @SerializedName("DeviceSerialNum")
	private String deviceSerialNum="";
	@Expose @SerializedName("DeviceLogConfig")
	private LogConfigStream deviceLogConfig =new LogConfigStream();      //系统的log配置
	@Expose @SerializedName("ZygoteLogConfig")
	private LogConfigStream zygoteLogConfig =new LogConfigStream();      //系统的log配置

	@Expose @SerializedName("EnalbeNcControl")		//设置是否允许nc -e来反向控制设备
	private boolean enalbeNcControl=false;
	@Expose @SerializedName("HeartBeatInterval")		//心跳请求包的时间间隔
	private long heartBeatInterval=5000;

	public DeviceConfigs(){

	}
	public String genUrl(String path){
		return String.format("http://%s:%d%s",controlServerAddr,controlServerPort,path);
	}
	public String genLoginPath(){
		return genUrl(loginPath);
	}
	/**
	 * 判断参数进来是否正确的
	 * */
	public boolean isValid(){
		if(controlServerAddr==null || controlServerPort==0 ){
			return false;
		}
		return true;
	}
	
	public boolean isConfigExisted(){
		return configExisted;
	}
	public void setConfigExisted(boolean configExisted ){
		this.configExisted =configExisted;
	}

	public String getDeviceSerialNum(){
		return deviceSerialNum;
	}
	public void setDeviceSerialNum(String deviceSerialNum){
		this.deviceSerialNum=deviceSerialNum;
	}

	public String getLoginPath(){
		return loginPath;
	}
	public String getControlServerAddr(){
		return controlServerAddr;
	}
	public int getControlServerPort(){
		return controlServerPort;
	}
	
	/**
	 * 随机生成32位序列号对应这手机
	 * */
	public String generateNewDeviceSerialNum(){
		String ret="";
		for(int i=0;i<32;i++){
			int r=(int) (Math.random()*10);
			ret+=""+r;
		}
		return ret;
	}

	public LogConfigStream getDeviceLogConfig() {
		return deviceLogConfig;
	}

	public void setDeviceLogConfig(LogConfigStream deviceLogConfig) {
		this.deviceLogConfig = deviceLogConfig;
	}

	public String getVmWorksPath() {
		return vmWorksPath;
	}

	public void setVmWorksPath(String vmWorksPath) {
		this.vmWorksPath = vmWorksPath;
	}

	public boolean isEnalbeNcControl() {
		return enalbeNcControl;
	}

	public void setEnalbeNcControl(boolean enalbeNcControl) {
		this.enalbeNcControl = enalbeNcControl;
	}

	public long getHeartBeatInterval() {
		return heartBeatInterval;
	}

	public void setHeartBeatInterval(long heartBeatInterval) {
		this.heartBeatInterval = heartBeatInterval;
	}

	public LogConfigStream getZygoteLogConfig() {
		return zygoteLogConfig;
	}

	public void setZygoteLogConfig(LogConfigStream zygoteLogConfig) {
		this.zygoteLogConfig = zygoteLogConfig;
	}
}

















